import { Router } from 'express'
import { auth } from '../../middleware/auth'
import { validate } from '../../middleware/validate'
import { gameValidation } from '../../validations/game.validation'
import { GameController } from './GameController'

const router = Router()
const gameController = new GameController()

// 创建游戏
router.post('/create', auth, validate(gameValidation.createGame), gameController.createGame)

// 下注
router.post('/bet', auth, validate(gameValidation.placeBet), gameController.placeBet)

// 获取游戏列表
router.get('/list', auth, validate(gameValidation.getGames), gameController.getGames)

// 获取游戏详情
router.get('/:gameId', auth, validate(gameValidation.getGameById), gameController.getGameById)

// 获取游戏结果
router.get(
  '/:gameId/result',
  auth,
  validate(gameValidation.getGameResult),
  gameController.getGameResult
)

// 获取游戏记录
router.get('/records', auth, validate(gameValidation.getGameRecords), gameController.getGameRecords)

// 获取游戏统计
router.get('/stats', auth, validate(gameValidation.getGameStats), gameController.getGameStats)

// 获取排行榜
router.get(
  '/rankings',
  auth,
  validate(gameValidation.getGameRankings),
  gameController.getGameRankings
)

export { router as gameRouter }
